From 3a76bf0ea622e233cad1f871901eb25e4b40ec3f Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Fri, 9 Jan 2015 17:31:45 +0100 Subject: [PATCH] rwlock: allow arch to override write_unlock() atomic ... (for consistency with read_unlock()), and default it to xchg(), being generally cheaper than cmpxchg(). Signed-off-by: Jan Beulich Reviewed-by: Tim Deegan Reviewed-by: Andrew Cooper --- xen/common/spinlock.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xen/common/spinlock.c b/xen/common/spinlock.c index f6925ec5f7..5fd8b1c84c 100644 --- a/xen/common/spinlock.c +++ b/xen/common/spinlock.c @@ -438,10 +438,14 @@ int _write_trylock(rwlock_t *lock) return 1; } -void _write_unlock(rwlock_t *lock) +#ifndef _raw_write_unlock +# define _raw_write_unlock(l) xchg(&(l)->lock, 0) +#endif + +inline void _write_unlock(rwlock_t *lock) { preempt_enable(); - if ( cmpxchg(&lock->lock, RW_WRITE_FLAG, 0) != RW_WRITE_FLAG ) + if ( _raw_write_unlock(lock) != RW_WRITE_FLAG ) BUG(); } -- 2.30.2